<?php
include_once(__DIR__."/api/src/CorpAPI.class.php");
include_once(__DIR__."/api/src/ServiceCorpAPI.class.php");
include_once(__DIR__."/api/src/ServiceProviderAPI.class.php");
include_once(__DIR__.'/callback/WXBizMsgCrypt.php');
include_once(__DIR__.'/utils/HttpUtils.class.php');

$updatedApprovals = "202112160001, 202112160002";
$time = date("Y-m-d_H-i-s");

$jsonContent = <<<jsonFile
{
    "creator_userid" : "KuaiJiA", 
    "template_id" : "3WK7SyDRLAk1JQKUu5s1Q32FrdGAsMTmGFNmDifS", 
    "use_template_approver" : 1, 
    "apply_data" : {
        "contents" : [{
            "control" : "Textarea", 
            "id" : "Textarea-1639617994478", 
            "value" : {
                "text" : "$updatedApprovals"
            }
        }]
    }, 
    "summary_list" : [{
        "summary_info" : [{
            "text" : "[$time]", 
            "lang" : "zh_CN"
        }]
    }, {
        "summary_info" : [{
            "text" : "$updatedApprovals", 
            "lang" : "zh_CN"
        }]
    }]
}
jsonFile;

//echo $jsonContent;
//echo "<br />";

//$output = HttpUtils::httpPost("http://localhost:8080", "hello");
//var_dump($output);

// 
$config = require('./config.php');
$api = new CorpAPI($config['CORP_ID'], $config['APPROVAL_APP_SECRET']);

try {
    //$ApprovalDataList = $api->ApprovalDataGet(1513649733, 1513770113);
    //var_dump($ApprovalDataList);
    $sp_no = $api->ApplyEvent($jsonContent);
    echo "<br />";
    var_dump($sp_no);
    echo "<br />";
}
catch (Exception $e) { 
    echo "<br />";
    echo "Error: " . $e->getMessage();
    echo "<br />";
}


?>
